<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Chapter 14. Berkeley DB Slice Support</title>
    <link rel="stylesheet" href="gettingStarted.css" type="text/css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" />
    <link rel="start" href="index.html" title="Berkeley DB Programmer's Reference Guide" />
    <link rel="up" href="index.html" title="Berkeley DB Programmer's Reference Guide" />
    <link rel="prev" href="rep_ex_chan.html" title="Ex_rep_chan: a Replication Manager channel example" />
    <link rel="next" href="slice-apis.html" title="Slice APIs" />
  </head>
  <body>
    <div xmlns="" class="navheader">
      <div class="libver">
        <p>Library Version 12.1.6.2</p>
      </div>
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">Chapter 14. Berkeley DB Slice Support</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="rep_ex_chan.html">Prev</a> </td>
          <th width="60%" align="center"> </th>
          <td width="20%" align="right"> <a accesskey="n" href="slice-apis.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="chapter" lang="en" xml:lang="en">
      <div class="titlepage">
        <div>
          <div>
            <h2 class="title"><a id="bdb_slices"></a>Chapter 14. Berkeley DB Slice Support</h2>
          </div>
        </div>
      </div>
      <div class="toc">
        <p>
          <b>Table of Contents</b>
        </p>
        <dl>
          <dt>
            <span class="sect1">
              <a href="bdb_slices.html#slice-enable">Enabling Slices</a>
            </span>
          </dt>
          <dt>
            <span class="sect1">
              <a href="slice-apis.html">Slice APIs</a>
            </span>
          </dt>
          <dt>
            <span class="sect1">
              <a href="slice-keys.html">Key Design</a>
            </span>
          </dt>
        </dl>
      </div>
      <p> 
        It is possible to improve the multiprocessor scaling of your DB
        databases by implementing <span class="emphasis"><em>slices</em></span>. Slices cause
        your database records to be spread evenly across sub-environments
        and sub-databases using an internal hashing algorithm. Because your
        records are stored in separate physical environments and databases,
        this allows for better parallel processing support by spreading read and
        write workloads across separate, discrete processor cores.
    </p>
      <p>
        To use slices, you must enable slice support for your library at
        compile time. You must also configure your environment and database
        to support slices. Optionally, you can also indicate which portion
        of your keys are <span class="emphasis"><em>slice-relevant</em></span>; that is,
        which portions of your keys are used to determine which slice they
        belong to.
    </p>
      <p>
        Be aware that use of slices has some ramifications when it comes to transactional
        processing of of multiple records within a single transaction.
        Because your records are distributed not just across physical
        databases, but also across physical environments, atomic operations
        can only be performed on records contained within the same physical
        slice.
    </p>
      <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
        <h3 class="title">Note</h3>
        <p>
            Slices are only supported for databases using the BTree and
            Hash access methods. Also, slices are not supported for
            in-memory only databases, or for sub-databases.
        </p>
      </div>
      <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
        <h3 class="title">Note</h3>
        <p>
            Slices are not supported for Windows in this release.
        </p>
      </div>
      <div class="sect1" lang="en" xml:lang="en">
        <div class="titlepage">
          <div>
            <div>
              <h2 class="title" style="clear: both"><a id="slice-enable"></a>Enabling Slices</h2>
            </div>
          </div>
        </div>
        <p>
            To create a sliced database, do all of the following:
        </p>
        <div class="orderedlist">
          <ol type="1">
            <li>
              <p>
                    Enable slices when you compile your DB library. Use
                    the <code class="literal">--enable-slices</code> configuration
                    option when compiling a *nix version of the library.
                </p>
            </li>
            <li>
              <p>
                    Configure slice support for your environment using the
                    <a href="../api_reference/C/set_slice_count_parameter.html" class="olink">set_slice_count</a> DB_CONFIG parameter. This
                    parameter simply identifies the total number of slices
                    you want to use. For best performance, the number of
                    slices you configure should be equal to the number of
                    cores available on your platform.
                </p>
              <p>
                    Because using slices means that a sub-environment is created
                    for each slice, it is sometimes necessary to perform
                    configuration on a sub-environment basis. You can do this using
                    the <a href="../api_reference/C/slice_parameter.html" class="olink">slice</a> DB_CONFIG parameter.
                </p>
            </li>
            <li>
              <p>
                    Open your database so that it supports slices. Use the
                    <code class="literal">DB_SLICED</code> flag with the <a href="../api_reference/C/dbopen.html" class="olink">DB-&gt;open()</a>
                    method to do this. Note that this flag is only required
                    when you initially create the database. After that,
                    using the database will be open with sliced support
                    regardless of whether the flag is present.
                </p>
            </li>
          </ol>
        </div>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="rep_ex_chan.html">Prev</a> </td>
          <td width="20%" align="center"> </td>
          <td width="40%" align="right"> <a accesskey="n" href="slice-apis.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">Ex_rep_chan: a Replication Manager channel example </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> Slice APIs</td>
        </tr>
      </table>
    </div>
  </body>
</html>
